package org.james.deleter.components;

import java.util.Arrays;

import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ListView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Modality;
import javafx.stage.Stage;

public class FileExtensionsPopup extends Stage {

	private static final String[] extensions = new String[]{
		".torrent",".mkv",".mp4",".txt",".exe",".pdf",".zip",".doc",".docx",".ppt",".pptx",
		".xls",".xlsx"
	};
	private BorderPane root = new BorderPane();
	private ListView<CheckBox> extensionList = new ListView<CheckBox>();
	private HBox hbox = new HBox();
	private Button confirmBtn = new Button("确定");
	
	public FileExtensionsPopup(){
		super();
		this.initialize();
	}
	
	public void initialize(){
		extensionList.setMaxHeight(200);
		Arrays.parallelSort(extensions);
		Arrays.stream(extensions).forEach((extens) -> {
			extensionList.getItems().add(new CheckBox(extens));
		});
		
		hbox.getChildren().addAll(confirmBtn);
		hbox.setAlignment(Pos.CENTER);
		hbox.setPadding(new Insets(15, 12, 10, 12));
		hbox.setSpacing(45); // Gap between nodes
		
		root.setTop(extensionList);
		root.setBottom(hbox);
		
		Scene scene=new Scene(root,200,400);
		this.setFullScreen(false);
		this.setResizable(false);
		this.initModality(Modality.APPLICATION_MODAL);  
		this.setScene(scene);

	}

	public Button getConfirmBtn() {
		return confirmBtn;
	}

	public void setConfirmBtn(Button confirmBtn) {
		this.confirmBtn = confirmBtn;
	}

	public ListView<CheckBox> getExtensionList() {
		return extensionList;
	}

	public void setExtensionList(ListView<CheckBox> extensionList) {
		this.extensionList = extensionList;
	}
	
	
	
}
